package learn.ch1;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Description todo
 * @Author yusj
 * @Date 2021/12/11
 * @Version 1.0
 */
public class TsCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        Thread.sleep(2000);
        return "after call";
    }

    public static void main(String[] args) {

        try {
            FutureTask futureTask=new FutureTask(new TsCallable());
            new Thread(futureTask).start();
            System.out.println("begin...");
            System.out.println(futureTask.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}
